class ChatService:
    def __init__(self, openai_client):
        self.client = openai_client

    def process_chat(self, query, image_url=None):
        """处理聊天请求"""
        # 构建消息内容
        message_content = [{"type": "text", "text": query}]
        
        if image_url:
            message_content.append({
                "type": "image_url",
                "image_url": {"url": image_url}
            })

        # 调用 OpenAI API
        completion = self.client.chat.completions.create(
            model="qwen-vl-plus",
            messages=[{
                "role": "user",
                "content": message_content
            }]
        )

        return completion.choices[0].message.content